<template>
<slot :controller="controller" :store="store" :model="model">
    <AppBasisViewLayout :class="classNames" :openType="openType">
        <template v-if="!noViewCaption && model.showCaption" #viewHeaderContentLeft>
            <div class="view-header__caption">
                <slot name="ViewCaption" :controller="controller" :store="store" :model="model">
                    <AppCaptionBar :caption="model.caption" :title="model.title" :capPSLanguageRes="model.capPSLanguageRes" :titlePSLanguageRes="model.titlePSLanguageRes" :openType="openType"></AppCaptionBar>
                </slot>
            </div>
        </template>
        <template #default>
            <AppTodoList />
        </template>
    </AppBasisViewLayout>
</slot>
</template>
<script lang="ts" setup>
// 基于template/src/views/{{appModules}}/{{pages@APPPANELVIEW}}/{{spinalCase page.codeName}}-base.vue.hbs生成
import { AppBasisViewLayout } from "@components/layout/basis-view-layout";
import { useProps, useBasic, useAction, useController } from './app-panel-view-hook';
import { IEvent, AppPanelViewActionType, IAppPanelViewAbility, IAppPanelViewStore, IParam } from '@/core';

// 输入参数
const props = defineProps(useProps());

// 基础数据
const { 
    model,
    getClassNames, 
    useNavParamsBind,
	useEventBind,
    handleQuickSearch,
  	handleToolbarItemClick,
    handleComponentAction,
	handleCtrlAction,
	handleCtrlInit,
	handleCtrlDestroy
} = useBasic(props);

const emit = defineEmits<{
    (event: 'view-action', name: string, action: AppPanelViewActionType, data: IParam[]): void;
    (event: 'view-init', name: string, data: IAppPanelViewAbility): void;
    (event: 'view-mounted', name: string, data: IParam): void;
    (event: 'view-destroy', name: string, data: IParam): void;
}>();

const evt = useEventBind(emit);
const classNames = computed(() => {
  	return getClassNames(props);
});

// 初始化控制器
const controller = useController(props, evt);

useNavParamsBind(controller, props);

const store: IAppPanelViewStore = controller.getStore();

onMounted(() => {
    controller.viewMounted();
})

onUnmounted(() => {
    controller.viewDestroy();
})
</script>
